package com.nowcoder.community.dao;

import com.nowcoder.community.entity.LoginTicket;
import org.apache.ibatis.annotations.*;

/**
 * <p>Title: LoginTicketMapper</p>
 * <p>author 12427</p>
 *
 * @version ver1.0
 * @date 2022/7/21 22:29
 */

@Mapper
@Deprecated // 声明不推荐使用
public interface LoginTicketMapper {

    // 1.  插入一个凭证
    @Insert({
            "insert into login_ticket (user_id , ticket , status , expired) " ,
            "values(#{userId},#{ticket},#{status},#{expired}) "
    })
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertLoginTicket(LoginTicket loginTicket);

    // 2. 利用ticket查询用户userid
    @Select({
            "select id , user_id , ticket , status , expired ",
            "from login_ticket where ticket=#{ticket}"
    })
    LoginTicket selectByTicket(String ticket) ;

    // 3.修改凭证状态
    @Update({
            "update login_ticket set status=#{status} where ticket=#{ticket} "
    })
    int updateStatus(String ticket , int status) ;





}
